var pageii = null;
var grid = null;
$(function() {
	grid = lyGrid({
		pagId : 'paging',
		l_column : [ {
			colkey : "id",
			name : "id"
		},{
			colkey : "Date",
			name : "日期",
			renderData : function(rowindex,data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
		}
		},{
			colkey : "Machine_Number",
			name : "机台号"
		}, {
			colkey : "Mold_Number",
			name : "模具号"
		}, {
			colkey : "Stay_Moulding",
			name : "待装模时间"
		},{
			colkey : "Moulding",
			name : "装模时间"
		},{
			colkey : "Actual_Moulding",
			name : "实际时间"
		},{
			colkey : "Check_Machine",
			name : "调机检查时间",
		},{
			colkey : "Determine",
			name : "判定",
			renderData : function(rowindex,data, rowdata, column) {
				if(data=='1'){
					return "合格";
				}else{
					return "不合格";
				}	
		}
		},{
			colkey : "Exception_Remake",
			name : "异常处理"
		},{
			colkey : "Status",
			name : "状态"
		},{
			colkey : "operation",
			name : "操作"
		},],
		jsonUrl : rootPath + '/progress/statistics_findByPage.shtml',
		dymCol:true,
		checkbox : true,
		serNumber : false
	});
	$("#editFun").click("click", function() {
		editAccount();
	});

	$("#delFun").click("click", function() {
		delAccount();
	});

	$("#search").click("click", function() {// 绑定查询按扭
		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
		});
	});
	
});


function delAccount() {
var cbox = grid.getSelectedCheckbox();
if (cbox == "") {
	layer.msg("请选择删除项！！");
	return;
}
layer.confirm('是否删除？', function(index) {
	var url = rootPath + '/progress/statistics_deleteEntity.shtml';
	var s = CommnUtil.ajax(url, {
		ids : cbox.join(",")
	}, "json");
	if (s == "success") {
		layer.msg('删除成功');
		grid.loadData();
		
	} else {
		layer.msg('删除失败');
	}
});

}
function editAccount() {
var cbox = grid.getSelectedCheckbox();
if (cbox.length > 1 || cbox == "") {
	layer.msg("只能选中一个");
	return;
}
pageii = layer.open({
	title : "编辑订单",
	type : 2,
	area : [ "800px", "100%" ],
	content : rootPath + '/progress/statistics_edit.shtml?id=' + cbox
});
}